function extractData(obj){
    return {x:obj.Horsepower, y:obj.Miles_per_Gallon}
}

function removeErrors(obj){
    return obj.x != null && obj.y != null;
}

function tfPlot(values,surface){
    tfvis.render.scatterplot(surface,
        {values:values,series:["Original",'Predicted']},
        {xLabel:'Horsepower',yLabel:"MPG"}
    );
}

async function runTF(){

    let jsonData = await fetch("./res/carsData.json");
    let values = await jsonData.json();
    values = values.map(extractData).filter(removeErrors);

   const surface1 = document.getElementById("plot1");
   const surface2 = document.getElementById("plot2");

   tfPlot(values,surface1);



        // document.getElementById("demo").innerHTML = text;
}

await runTF();
